package com.cxg.fairy.ec.main.personal.list;

import android.graphics.Color;
import android.support.v7.widget.AppCompatTextView;

import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.RequestOptions;
import com.cxg.fairy.ec.main.personal.message.MessageItemType;
import com.cxg.fairy.ui.recycler.MultipleFields;
import com.cxg.fairy.ui.recycler.MultipleItemEntity;
import com.cxg.fairy.ui.recycler.MultipleRecyclerAdapter;
import com.cxg.fairy.ui.recycler.MultipleViewHolder;
import com.diabin.latte.ec.R;
import com.joanzapata.iconify.widget.IconTextView;

import java.util.List;

/**
 * Created by CFairy
 */

public class MsgListAdapter extends MultipleRecyclerAdapter {

    private static final RequestOptions OPTIONS = new RequestOptions()
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .dontAnimate()
            .centerCrop();

    public MsgListAdapter(List<MultipleItemEntity> data) {
        super(data);
        addItemType(ListItemType.ITEM_IMG,R.layout.arrow_item_img);
    }

    @Override
    protected void convert(final MultipleViewHolder holder, final MultipleItemEntity entity) {
                int itemId = entity.getField(MultipleFields.ID);
                final String title = entity.getField(MultipleFields.NAME);
                final String content = entity.getField(MultipleFields.TAG);
                final int itemType = entity.getField(MultipleFields.ITEM_TYPE);

                final IconTextView imgIconText = holder.getView(R.id.itv_arrow_item_img);
                final AppCompatTextView titleText = holder.getView(R.id.tv_msg_center_title);
                final AppCompatTextView contentText = holder.getView(R.id.tv_msg_center_content);

                switch (itemId) {
                    case 1:
                        holder.setText(R.id.itv_arrow_item_img, "{icon-msg-center-my-funds}");
                        break;
                    case 2:
                        holder.setText(R.id.itv_arrow_item_img, "{icon-msg-center-order-notice}");
                        holder.setBackgroundColor(R.id.itv_arrow_item_img, Color.parseColor("#5884ff"));
                        holder.setText(R.id.tv_msg_center_title, holder.itemView.getResources().getString(R.string.msg_center_order_notice));
                        break;
                    case 3:
                        holder.setText(R.id.itv_arrow_item_img, "{icon-msg-center-promote}");
                        holder.setBackgroundColor(R.id.itv_arrow_item_img, Color.parseColor("#6e32fc"));
                        holder.setText(R.id.tv_msg_center_title, holder.itemView.getResources().getString(R.string.msg_center_promote));
                        break;
                    case 4:
                        holder.setText(R.id.itv_arrow_item_img, "{icon-msg-center-os-notice}");
                        holder.setBackgroundColor(R.id.itv_arrow_item_img, Color.parseColor("#403f40"));
                        holder.setText(R.id.tv_msg_center_title, holder.itemView.getResources().getString(R.string.msg_center_sys_notice));
                        break;
                    default:
                        break;
                }

                titleText.setText(title);
                contentText.setText(content);
        }

}
